import java.util.Random;

public class test4 {
    public static void main(String[] args) {

        //抽奖 100 500 800
        int[] arr = {2, 500, 1000, 800, 3};
        //创建新的数组
        int[] newArr = new int[arr.length];
        //随机数
        Random r = new Random();
        for (int i = 0; i < 5; ) {
            int number = r.nextInt(arr.length);
            //获取奖项
            int price = arr[number];
            //判断是否存在，存在则随机抽取，不存在就能放进去
            boolean flag = contions(newArr, price);
            if (!flag) {
                //添加到newArr当中
                newArr[i] = price;
                i++;
            }
        }
        //遍历数组
        for (int i = 0; i < 5; i++) {
            System.out.println(newArr[i] + " ");
        }
    }


    //判断是否相等函数
    public static boolean contions(int[] newArr, int price) {
        for (int i = 0; i < newArr.length; i++) {
            if (price == newArr[i]) {
                return true;
            }
        }
        return false;
    }
}
